#include <iostream>
#include <algorithm>
using namespace std;
constexpr int MAXN = 100;
int start[MAXN], finish[MAXN];
pair<int, int> sf[MAXN];
int n;
// 这道贪心算法题的本质是如何找到最好的调度方式, 能够完成更多的工作
int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> start[i];
    for (int j = 0; j < n; j++) cin >> finish[j];
    for (int i = 0; i < n; i++) {
        sf[i].first = finish[i];
        sf[i].second = start[i];
    }
    sort(sf, sf + n);
    int result = 0, t = 0;
    for (int i = 0; i < n; i++) {
        if (t < sf[i].second) {
            t = sf[i].first;
            result++;
        }
        // bool skip = false;
        // while (i + 1 < n && sf[i + 1].second < last) {
        //     i++; skip = true;
        // }
        // if (skip) continue;
    }
    cout << result << endl;

}